import { fetchFactory, fetchStandardCode } from '@/api/dataset'

const state = {
  standardCode: [],
  factory: []
}

const mutations = {
  SET_STANDARD_CODE: (state, value) => {
    state.standardCode = value
  },
  SET_FACTORY: (state, value) => {
    state.factory = value
  }
}

const actions = {
  load({ dispatch }) {
    dispatch('getStandardCode')
    dispatch('getFactory')
  },
  async getStandardCode({ commit }) {
    const data = await fetchStandardCode()
    commit('SET_STANDARD_CODE', data)
  },
  async getFactory({ commit }) {
    const data = await fetchFactory()
    commit('SET_FACTORY', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

